<template>
    <component :is="iconType" :type="iconName" :color="iconColor" :size="iconSize"></component>
</template>

<script>
    import Icons from '_c/icons'

    export default {
        name: "common-icon.vue",
        components: {Icons},
        props: {
            type: {
                type: String,
                require: true
            },
            color: String,
            size: Number
        },
        computed: {
            iconType() {
                return this.type.indexOf('_') === 0 ? 'Icons' : 'icon'
            },
            iconName() {
                return this.iconType === 'Icons' ? this.getCustomIconName(this.type) : this.type
            },
            iconSize() {
                return this.size || (this.iconType === 'Icons' ? 12 : undefined)
            },
            iconColor() {
                return this.color || ''
            }
        },
        getCustomIconName(iconName) {
            return iconName.slice(1)
        }
    }
</script>

<style scoped>

</style>

